<?php
if ( !defined('IN_ADMINCP') || !defined('IN_SEC') ){
	exit('Access Denied.');
}

$admin = $admincp->admin;
if ( is_post() ){
	$account = new admincp_account();
	$confirm = $_G['gp_confirm'] ? $account->password($_G['gp_confirm']) : $admincp->cpmsg('请输入原密码');
	$password = $_G['gp_password'] ? $_G['gp_password'] : $admincp->cpmsg('请输入新密码');
	$confirmpass = $_G['gp_confirmpass'] ? $_G['gp_confirmpass'] : $admincp->cpmsg('请输入确认新密码');
	if ( $password != $confirmpass ){
		$admincp->cpmsg('新密码输入错误');
	}
	if ( $admincp->admin['password'] != $confirm ){
		$admincp->cpmsg('原密码不正确');
	}
	$update = $account->edit(array(
		'id' => $admin['id'],
		'password' => $admin['password']
	));

	$update ? $admincp->success() : $admincp->cpmsg('修改失败,系统繁忙');
}
dialog('admin_account_setting');